package com.teangtang.fly.controller;

import com.teangtang.fly.dto.CityDto;
import com.teangtang.fly.entity.City;
import com.teangtang.fly.entity.Food;
import com.teangtang.fly.entity.Province;
import com.teangtang.fly.get.CityWithProvince;
import com.teangtang.fly.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/food")
public class FoodController {
    @Autowired
    private FoodService foodService;

    @GetMapping
    public ResponseEntity<List<Food>> getAllFoods() {
        List<Food> foods = foodService.getAllFoods();
        return new ResponseEntity<>(foods, HttpStatus.OK);
    }

    @GetMapping("/{id}")
    public Food getFoodById(@PathVariable Long id) {
        return foodService.getFoodById(id);
    }

    @PostMapping
    public ResponseEntity<Food> createCity(@RequestBody Food food) {
        foodService.createFood(food);
        return new ResponseEntity<>(food, HttpStatus.OK);
    }
    @PutMapping("/{id}")
    public Food updateFood(@PathVariable Long id, @RequestBody Food food) {
        return foodService.updateFood(id, food);
    }

    @DeleteMapping("/{id}")
    public void deleteFood(@PathVariable Long id) {
        foodService.deleteFood(id);
    }
}
